from django.contrib import admin
from .models import Post, Comment, SupportGroup


@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    """树洞帖子管理"""
    list_display = ['id', 'user', 'title', 'is_anonymous', 'view_count', 'like_count', 'status', 'audit_status', 'created_at']
    list_filter = ['is_anonymous', 'status', 'audit_status', 'created_at']
    search_fields = ['title', 'content', 'user__username']
    date_hierarchy = 'created_at'
    ordering = ['-created_at']


@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
    """帖子评论管理"""
    list_display = ['id', 'post', 'user', 'is_anonymous', 'is_warm_response', 'like_count', 'audit_status', 'created_at']
    list_filter = ['is_anonymous', 'is_warm_response', 'audit_status', 'created_at']
    search_fields = ['content', 'user__username']
    date_hierarchy = 'created_at'
    ordering = ['created_at']


@admin.register(SupportGroup)
class SupportGroupAdmin(admin.ModelAdmin):
    """互助小组管理"""
    list_display = ['id', 'group_name', 'topic', 'creator', 'max_members', 'is_active', 'created_at']
    list_filter = ['topic', 'is_active', 'created_at']
    search_fields = ['group_name', 'description', 'creator__username']
    ordering = ['-created_at']
